//
//  TG_UIHelper.h
//  TongGuanLease
//
//  Created by 张奇 on 2022/4/12.
//

/**
 *  判断IOS7或者IOS6以下，YES为7，NO为6以下
 */
#define OSVersionIsAtLeastiOS7 (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)
#define IOS8  [[[UIDevice currentDevice]systemVersion] doubleValue] >= 8.0
#define IOS9  [[[UIDevice currentDevice]systemVersion] doubleValue] >= 9.0
#define IOS10 [[[UIDevice currentDevice]systemVersion] doubleValue] >= 10.0
#define IOS10Less [[[UIDevice currentDevice]systemVersion] doubleValue] <= 10.0

#define Height_StatusBar ((IS_IPHONE_X == YES || IS_IPHONE_Xr == YES || IS_IPHONE_Xs == YES || IS_IPHONE_Xs_Max == YES) ? 44.0 : 20.0)

#define Height_TabBar_SafeBottom  ((IS_IPHONEX==YES)? 34.0:0)


#define NavHeight NavBarHeight


#define NavBarHeight  (kDeviceIPhoneX?88.0:64.0)// NavHeight//(Height_StatusBar+NavHeight)

//#define TabBarHeight (kDeviceIPhoneX?83.0:49.0)//((IS_IPHONE_X == YES || IS_IPHONE_Xr == YES || IS_IPHONE_Xs == YES || IS_IPHONE_Xs_Max == YES) ? 83.0 : 49.0)

#define TGTabBarHeight (kDeviceIPhoneX?83.0:49.0)//((IS_IPHONE_X == YES || IS_IPHONE_Xr == YES || IS_IPHONE_Xs == YES || IS_IPHONE_Xs_Max == YES) ? 83.0 : 49.0)


// 判断是否是ipad
#define kisPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
// 判断iPhone4系列
#define kiPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) && !kisPad : NO)
// 判断iPhone5系列
#define kiPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) && !kisPad : NO)
// 判断iPhone6系列
#define kiPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) && !kisPad : NO)
//判断iphone6+系列
#define kiPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) && !kisPad : NO)
// 判断iPhoneX
#define IS_IPHONE_X ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !kisPad : NO)
// 判断iPHoneXr
#define IS_IPHONE_Xr ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) && !kisPad : NO)
// 判断iPhoneXs
#define IS_IPHONE_Xs ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !kisPad : NO)
// 判断iPhoneXs Max
#define IS_IPHONE_Xs_Max ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) && !kisPad : NO)

/**
 *  判断屏幕4英寸还是3.5英寸，YES为Iphone5，NO为Iphone4
 */
#define OSRetinaIs4inch ([UIScreen mainScreen].bounds.size.height > 480)
#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
#define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)
#define IS_IPHONEX  kDeviceIPhoneX
#define kDeviceIPhoneX [TG_UIHelper isIphoneX]

#define IS_CHECKPass [TG_UIHelper isPass]

//ios 比例计算
#define RatioWidth(A)  floorInPixel([TG_UIHelper ratioWidth:A])
#define RatioHeight(A) ceil((A)*kWJHeightCoefficient)
#define ZLRatioHeight(A)  floorInPixel([TG_UIHelper ratioHeight:A])
#define kWJHeightCoefficient ((PhoneScreen_HEIGHT == 812.0 ? 667.0/667.0 : PhoneScreen_HEIGHT/667.0))
#define AverageFloat(x,y) fabs((x - y)/2)

#define MIN_HEIGHT(A) MAX(A,RatioHeight(A))
#define MIN_WIDTH(A)  MAX(A,RatioWidth(A))

#define CGRectAutoMake(x,y,w,h) CGRectMakeAuto(x,y,w,h)

#define lineWidth(A) ([[UIScreen mainScreen] scale] > 0.0 ? A / [[UIScreen mainScreen] scale] : A)


#define TGAutoFont(R) [TG_UIHelper TGAutoFount:R name:Ping_Regular]
#define TGBlodAFont(R) [TG_UIHelper TGAutoFount:R name:Ping_Semibold]
#define TGLightAFont(R) [TG_UIHelper TGAutoFount:R name:Ping_Light]
#define TGThinAFont(R) [TG_UIHelper TGAutoFount:R name:Ping_Light]
//#define TGMediumAFont(R) [TG_UIHelper TGAutoFount:R name:Ping_Medium]
//UI让都用细的，统一修改
#define TGMediumAFont(R) [TG_UIHelper TGAutoFount:R name:Ping_Regular]
#define TGSemiboldFont(R) [TG_UIHelper TGAutoFount:R name:Ping_Semibold]
#define TGHeavyFont(R) [TG_UIHelper TGAutoFount:R name:Ping_Heavy]

//我的里面的
#define TableViewSpace (RatioWidth(14))
#define TitleTextFont  TGAutoFont(15)

#define TitleBlodFont  TGBlodAFont(14)
#define TitleDetailFont TGAutoFont(13)

#define TitleBlackColor RGB(51,51,51)
#define TitleLightGrayColor RGB(153,153,153)
#define UIColorDeepRed  RGBA(229, 28, 35, 1)

#define KLeftleftTableViewWidth  RatioWidth(90)

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface TG_UIHelper : NSObject
+ (instancetype)sharedInstance;
+ (UIFont *)fontOfSize:(int)font;
+ (UIFont *)boldFontOfSize:(int)font;
+ (CGFloat)autoHeight:(CGFloat)f;
+ (UIFont *)TGAutoFount:(CGFloat)f name:(NSString *)name;
+ (BOOL)isIphoneX;

/*比例计算宽高，iPhone 6 尺寸基准*/
+ (CGFloat)ratioWidth:(CGFloat)f;
+ (CGFloat)ratioHeight:(CGFloat)f;

///打印所有字体
+(void)fontFamilyNames;
@end

NS_ASSUME_NONNULL_END
